package com.fengxu.springcloud.service;

import com.fengxu.springcloud.entity.CommonResult;
import com.fengxu.springcloud.entity.Payment;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@Service
// 这里写你的服务名，feign会根据服务名获取服务的uri地址然后调用服务提供者对外暴露的controller接口
@FeignClient(name = "CLOUD-PAYMENT-SERVICE")
public interface PaymentFeignService {

    /**
     * 下面的接口要更服务的controller层定义的方法一致
     * 1. 下面的服务要映射注册中心的服务的controller接口，所以服务路径要写全
     * 2. 像是需要传参的服务要在requestMapping中写全如@RequestMapping(/find?name={name})
     */

    @GetMapping("/api/payment/find/{id}")
    CommonResult getPaymentById(@PathVariable("id") Long id);

    @PostMapping("/api/payment/create")
    CommonResult create(@RequestBody Payment payment);

    @GetMapping("/api/payment/timeout")
    String timeout();
}
